/**
 * 用法
 * 获取值：LocalStorageX.data
 * 设置值：LocalStorageX.data=xxxx
 */
const LocalStorageX = new Vue({
  data: {
    data: JSON.parse(localStorage.getItem('LocalStorageX') || '{}'),
  },
  watch: {
    'data': {
      handler(newValue) {
        this.setData(newValue)
      },
      deep: true
    }
  },
  methods: {
    setData(value) {
      this.$set(this, 'data', value)
      localStorage.setItem('LocalStorageX', JSON.stringify(value))
    }
  }
})

Vue.mixin({
  data() {
    return {
      LocalStorageX: LocalStorageX
    }
  }
})










